package org.chickymate.server.controller.command.dto;

import java.util.ArrayList;
import java.util.List;

import org.chickymate.client.model.CommentDTO;
import org.chickymate.server.model.Comment;


public class GetRecentCommentsCommand extends DTOAbstractCommand {

	public List<CommentDTO> execute() {
		return asDTO(getCommentDao().getRecentComments());
	}

	private List<CommentDTO> asDTO(List<Comment> comments) {
		List<CommentDTO> commentsDTO = new ArrayList<CommentDTO>(comments.size());
		for(Comment comment : comments) {
			commentsDTO.add(comment.asDTO());
		}
		return commentsDTO;
	}
}
